<div id="student-real-name-auth" title="实名认证">
    <form id="student-real-name-auth-form">
        <input type="hidden" name="user_id" value="<?php echo isset($thatUserId) ? $thatUserId : 0 ?>"/>

        <div class="input-group">
            <label for="school-id" class="input-group-addon">学校名称</label>
            <select id="school-id" name="school_id" class="form-control">
                <?php if (isset($SchoolArray) && sizeof($SchoolArray) > 0) : ?>
                    <?php foreach ($SchoolArray as $index => $thisSchool) : ?>
                        <?php /** @var CommodityCategory $thisSchool */ ?>
                        <?php if($index==0||$index==1||$index==5): ?>
                        <option value="<?php echo $thisSchool->getId(); ?>" <?php echo ($index == 0) ? 'selected="selected"' : ''; ?>>
                            <?php echo $thisSchool->getName(); ?>
                        </option>
                         <?php endif; ?>
                    <?php endforeach; ?>
                <?php endif; ?>
            </select>
        </div>
        <div class="input-group">
            <label for="student-num" class="input-group-addon">学生学号</label>
            <input type="text" class="form-control" name="student_num" id="student-num" autocomplete="off"/>
        </div>
        <div class="input-group">
            <label for="student-pwd" class="input-group-addon">教务密码</label>
            <input type="password" class="form-control" name="student_pwd" id="student-pwd" autocomplete="off"/>
        </div>
        <?php if (isset($captcha) || 1): ?>
            <!--div class="row">
                <div class="col-xs-8">
                    <div class="input-group">
                        <label for="captcha" class="input-group-addon">验证码</label>
                        <input type="text" class="form-control" name="captcha" id="captcha" placeholder="请输入验证码" autocomplete="off"/>
                    </div>
                </div>
                <div class="col-xs-4">
                    <div style="width: 100%; height: 50px; background: #000"></div>
                </div>
            </div-->
        <?php endif; ?>
        <div class="input-group">
            <input type="submit" class="btn btn-primary form-control" value="进行认证" style="font-size: 15px !important;"/>
        </div>
    </form>
</div>


<script>
    $(function () {
        $("#student-real-name-auth-form").validate({
            submitHandler: function (form) {
                $.ajax({
                    url: '<?php echo base_url('api/studentRealNameAuth');?>',
                    type: 'post',
                    data: $(form).serialize(),
                    beforeSend: function () {
                        showProgressNoty();
                    },
                    complete: function () {
                        closeProgressNoty();
                    },
                    success: function (jsonrsp) {
                        try {
                            var rsp = $.parseJSON(jsonrsp);
                            noty({type: rsp.type, text: rsp.message, callback: {
                                afterClose: function () {
                                    switch (rsp.type) {
                                        case 'success':
                                            location.reload();
                                            break;
                                        default:
                                            break;
                                    }
                                }
                            }});
                        } catch (ex) {
                            noty({type: 'error', text: '发生内部错误，请联系管理员'});
                            throw ex;
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        console.error(XMLHttpRequest, textStatus, errorThrown);
                        noty({type: 'error', text: '发生内部错误，请联系管理员'});
                    }
                });
            }
        });

    });
</script>